package com.wyw.controller;

import com.wyw.controller.frontend.MainPageController;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 拦截所有请求， 解析请求， 派发给的对应的controller里面的方法处理
 * 反斜杠虽然会匹配所有的请求，但是优先级最低
 * @author weiyuewen 2020/6/9 14:44
 */
@WebServlet("/")
public class DispatcherServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp){
        System.out.println("request path is " + req.getServletPath());
        System.out.println("request method is " + req.getMethod());
        if (req.getServletPath().equals("/frontend/getmainpageinfo") && req.getMethod().equals("GET")){
            new MainPageController().getMainPageInfo(req, resp);
        }
    }


}
